<template>
	<view class="content">
		<image :class="className" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title" @click="open">{{title}}</text>
		</view>
		<view>
			<view>{{ number +1}}</view>
			<view>{{ ok ? 'YES':'NO'}}</view>
			<view>{{ message.split('').reverse().join('')}}</view>
		</view>
		<view class="modelclass">
			<input v-model="message" placeholder="edit me">
			<text>Message is:{{ message}}</text>
		</view>
		<image class="logo" v-on:click="change" src="/static/logo.png"></image>
		<view v-if="!raining">今天天气好</view>
		<view v-if="raining">下雨在家</view>
		<view v-if="state==='vue'">state的值是 Vue</view>
		<view>state is {{state?'vue':APP}}</view>
		<view v-for="item in arr" style="color: black;">{{item}}</view>
		<view v-for="(item,index) in 4" style="color: aqua;">
			<view :class="'list-'+index%2">{{index%2}}</view>
		</view>
		<view v-for="(value,name,index) in Object">{{ index}}.{{name}}:{{value}}</view>
		<view v-for="item in arr" :key="item.id">
			<view style="color: blue;">{{item.id}}:{{item.name}}</view>
			<view class="content">
				<button @click="handleClick('参数1')">按钮1</button>
				<button @click="handleClick(dynamicParam)">按钮2</button>
				<button @click="handleClick('参数A','参数B',$event)">按钮3</button>
				<button @click="(e)=>handleButton('点击事件',e)">带事件对象</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				arr: [{
						id: 1,
						name: 'uni-app'
					},
					{
						id: 2,
						name: 'Html'
					}
				],
				object: {
					title: 'how to do lists in vue',
					author: 'jane doe',
					publishedAT: '2020.04.10'
				},
				raining: false,
				state: 'vue',
				dynamicParam: "我是动态参数",
				title: 'Hello UniAPP',
				Number: 1,
				ok: true,
				message: '1111',
				className: "smalllogo"
			}
		},
		onLoad() {

		},
		methods: {
			handleClick(param1, param2, event) {
				console.log("参数1:", param1)
				console.log("参数2:", param2)
				console.log("事件对象:", event)
			},
			handleButton(msg, event) {
				console.log('接收的消息:', msg)
				console.log('事件对象:', event)
				console.log('按钮文本:', event.target.textContent)
			},
			open() {
				this.title = "opening a new Page";
				this.className = 'logo'
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.smalllogo {
		height: 50rpx;
		width: 50rpx;
		margin-top: 200rpx;
		margin-right: auto;
		margin-left: auto;
		margin-bottom: 50rpx;
	}
</style>